import axios from "axios";
import store from "@/store";

const BASEURL = "http://xue.cnkdl.cn:8809";

export default function (url, data = {}, method = "GET", headers = {}) {
  // 写死，每一个请求都会携带上
  headers = Object.assign({}, headers, {
    "x-auth-token": store.state.loginToken,
  });
  return new Promise((resolve, reject) => {
    axios({
      url: BASEURL + url,
      data:data,
      method: method,
      headers: headers,
    })
      .then((res) => {
        resolve(res.data);
      })
      .catch((err) => {
        reject(err);
      });
  });
}
